/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo.generic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
import sun.security.x509.AttributeNameEnumeration;

/**
 *
 * @author VANDH
 */
public class Manager<T> {
    // Tạo một class EmployeeManager : add(Employee e),
    // remove(String name), list(), search(String name)
    // yêu cầu dùng Vector
    // Generic class

    Vector<T> employeeList = new Vector<>();

    public void add(T e) {
        employeeList.add(e);
    }

    // Wildcard, extends, super
    public void addAll(ArrayList<? extends T> e) {
        employeeList.addAll(e);
    }

    public void remove(String name) {
        Iterator i = employeeList.iterator();
        while (i.hasNext()) {
            T e = (T) i.next();

            if (e instanceof Employee) {
                if (((Employee) e).getName().equals(name)) {
                    i.remove();
                }
            }
        }
    }

    public void list() {
        for (Object i : employeeList) {
            T e = (T) i;
            System.out.println(e);
        }

    }

    public Employee search(String name) {
        return new Employee();
    }

    public ArrayList maxPayment() {
        return new ArrayList();
    }

    public ArrayList minPayment() {
        return new ArrayList();
    }
}
